
import 'dart:async';
import '../utils/ApiService.dart';
import 'definitions/ResultGroupModel.dart';
import 'definitions/ResultGroupList.dart';
import 'definitions/ResultUserList.dart';
import 'definitions/ResultModel.dart';
import 'definitions/CreateGroupModelParams.dart';


class GroupController {

    static String currentGroupUsingGetPath = "/api/group/current";
    /// 1. 获取默认分组
    static Future<ResultGroupModel> currentGroupUsingGet([dynamic headers]) async {
      var response = await ApiService.get("/api/group/current", {}, headers);
      return ResultGroupModel()..fromJson(response.data);
    }
    
    static String globalGroupUsingGetPath = "/api/group/global";
    /// 2. 获取世界分组
    static Future<ResultGroupList> globalGroupUsingGet([dynamic headers]) async {
      var response = await ApiService.get("/api/group/global", {}, headers);
      return ResultGroupList()..fromJson(response.data);
    }
    
    static String interestGroupsUsingGetPath = "/api/group/list/interest";
    /// 3. 获取所有的兴趣分组
    static Future<ResultGroupList> interestGroupsUsingGet([dynamic headers]) async {
      var response = await ApiService.get("/api/group/list/interest", {}, headers);
      return ResultGroupList()..fromJson(response.data);
    }
    
    static String listUsingGetPath = "/api/group/list";
    /// 4. 获取所有的用户分组
    static Future<ResultGroupList> listUsingGet([dynamic headers]) async {
      var response = await ApiService.get("/api/group/list", {}, headers);
      return ResultGroupList()..fromJson(response.data);
    }
    
    static String usersUsingGetPath = "/api/group/groupUsers/{id}";
    /// 5. 获取分组成员
    static Future<ResultUserList> usersUsingGet(String id, [dynamic headers]) async {
      var response = await ApiService.get("/api/group/groupUsers/$id", {}, headers);
      return ResultUserList()..fromJson(response.data);
    }
    
    static String createUsingPostPath = "/api/group/create";
    /// 6. 创建分组
    static Future<ResultModel> createUsingPost(CreateGroupModelParams data,[ dynamic headers ]) async {
      var response = await ApiService.post("/api/group/create", data.toJson() , headers);
      return ResultModel()..fromJson(response.data);
    }
    
    static String updateUsingPutPath = "/api/group/update/{id}";
    /// 7. 编辑分组名称
    static Future<ResultModel> updateUsingPut(String id, [ dynamic headers ]) async {
      var response = await ApiService.put("/api/group/update/$id", null, headers);
      return ResultModel()..fromJson(response.data);
    }
    
    static String inviteUserUsingPostPath = "/api/group/inviteUser";
    /// 8. 邀请分组成员
    static Future<ResultModel> inviteUserUsingPost(dynamic data,[ dynamic headers ]) async {
      var response = await ApiService.post("/api/group/inviteUser", data.toJson() , headers);
      return ResultModel()..fromJson(response.data);
    }
    
    static String removeUserUsingPostPath = "/api/group/removeUser";
    /// 9. 删除分组成员
    static Future<ResultModel> removeUserUsingPost(dynamic data,[ dynamic headers ]) async {
      var response = await ApiService.post("/api/group/removeUser", data.toJson() , headers);
      return ResultModel()..fromJson(response.data);
    }
    
    static String inviteListUsingPostPath = "/api/group/list/invite";
    /// 10. 邀请我的分组列表
    static Future<ResultModel> inviteListUsingPost([ dynamic headers ]) async {
      var response = await ApiService.post("/api/group/list/invite", null, headers);
      return ResultModel()..fromJson(response.data);
    }
    
    static String inviteByMeListUsingPostPath = "/api/group/list/inviteByMe";
    /// 11. 我邀请的分组列表
    static Future<ResultModel> inviteByMeListUsingPost([ dynamic headers ]) async {
      var response = await ApiService.post("/api/group/list/inviteByMe", null, headers);
      return ResultModel()..fromJson(response.data);
    }
    
    static String removeUsingPostPath = "/api/group/remove/{id}";
    /// 12. 删除分组 - 转交分组内容至别的分组
    static Future<ResultModel> removeUsingPost(String id, [ dynamic headers ]) async {
      var response = await ApiService.post("/api/group/remove/$id", null, headers);
      return ResultModel()..fromJson(response.data);
    }
    
    static String setCurrentUsingPostPath = "/api/group/setCurrent/{id}";
    /// 13. 设置默认分组 - 需要提前移除当前默认分组
    static Future<ResultModel> setCurrentUsingPost(String id, [ dynamic headers ]) async {
      var response = await ApiService.post("/api/group/setCurrent/$id", null, headers);
      return ResultModel()..fromJson(response.data);
    }
    
    static String detailUsingGetPath = "/api/group/detail/{id}";
    /// 13. 获取分组详情
    static Future<ResultGroupModel> detailUsingGet(String id, [dynamic headers]) async {
      var response = await ApiService.get("/api/group/detail/$id", {}, headers);
      return ResultGroupModel()..fromJson(response.data);
    }
    
}